<template>
  <el-container>
    <el-header height='80'>
      <headTop :show-site-switch='showSiteSwitch'>
      </headTop>
    </el-header>

    <div class="manage_page" v-if="showMenu">
      <el-row type='flex' justify='center'>
        <el-col :span="24" >
          <el-menu :default-active="defaultActive" class="el-menu-demo" mode="horizontal" router>
            <el-menu-item index="statistic" v-if="upAdmin">每日营销</el-menu-item>
            <el-menu-item index="orderquery"  v-if="role === 'PRINTER' || upAdmin">订单查询</el-menu-item>
            <el-menu-item index="usermanager" v-if="upAdmin">用户管理</el-menu-item>
            <!-- <el-menu-item index="moneymanager"  v-if='upAdmin'>调账管理</el-menu-item> -->
            <el-menu-item index="levelmanager" v-if="upAdmin">等级管理</el-menu-item>
            <el-menu-item index="expressmanager" v-if="upSuper">快递管理</el-menu-item>
            <el-menu-item index="giftmanager" v-if='upAdmin'>礼品管理</el-menu-item>
            <el-menu-item index="pricemanager" v-if='upAdmin'>价格管理</el-menu-item>
            <el-menu-item index="cainiao" v-if="upSuper">菜鸟快递</el-menu-item>
            <el-menu-item index="uploadexpress" v-if="upSuper">普通快递</el-menu-item>
            <el-menu-item index="batchmanager" v-if="upSuper">快递批量管理</el-menu-item>
            <el-menu-item index="depositmanager" v-if="upAdmin">充值管理</el-menu-item>
            <el-menu-item index="rolemanager" v-if="upSuper">角色管理</el-menu-item>
            <el-menu-item index="sitemanager" v-if="upSuper">分站管理</el-menu-item>
            <el-menu-item index="keyvaluemanager" v-if="upAdmin">配置管理</el-menu-item>
          </el-menu>
        </el-col>
      </el-row>
      
      <!-- <keep-alive> -->
      <router-view></router-view>
      <!-- </keep-alive> -->
    </div>
  </el-container>

</template>

<script>
    import headTop from '@/components/headTop'
    import {SUPER_ADMIN, STATION_ADMIN, PRINTER} from '@/utils/cookie'

    import { mapActions, mapMutations, mapState } from 'vuex';
    export default {
      components: {
        headTop
      },
      data () {
        return {
          showMenu: false
        }
      },
      computed: {
        ...mapState(['role']),
        defaultActive: function () {
          if (this.role === PRINTER) {
            return 'orderquery'
          } else {
            return this.$route.path.replace('/', '')
          }
        },
        showSiteSwitch: function () {
          return this.role === PRINTER
        },
        upPrinter: function () {
          return [STATION_ADMIN, SUPER_ADMIN, PRINTER].includes(this.role)
        },
        upAdmin: function () {
          return [STATION_ADMIN, SUPER_ADMIN].includes(this.role)
        },
        upSuper: function () {
          return this.role === SUPER_ADMIN
        }
      },
      methods: {
        ...mapActions('manage', ['getAllSites', 'getGiftList', 'getKktypeList']),
        async initData() {
          this.getGiftList()
          this.getKktypeList()
          if (this.role == SUPER_ADMIN || this.role == PRINTER) {
            await this.getAllSites()
          }
          this.showMenu = true
        }
      },
      mounted () {
        this.initData()
      }
    }
    
</script>


<style lang="less" scoped>
	@import '../../style/mixin';
	.manage_page{
    margin-top: 40px;
    padding: 0 40px;
	}
  // .el-menu-demo {
  // }
</style>
